//  数据查询Js
var query = {
    //  查询用户权限菜单
    queryUserMenus: function () {
        $.ajax({
            url: '../users/queryUserMenus',
            type: 'get',
            dataType: 'json',
            data: {userName: ''},
            async: false,
            success: function (data) {
                var strHtml = "";
                $(data).each(function (i, e) {
                    if (e.parentcode == '00') {
                        if (e.childs > 0) {
                            strHtml += '<li>'
                                + '<a href="#"><i class="fa ' + e.iconstyle + '"></i> '
                                + '<span  class="nav-label">' + e.menuname + '</span>'
                                + '<span class="fa arrow"></span>'
                                + '</a>';
                            strHtml += '<ul class="nav nav-third-level">';
                            strHtml += query.loadMenus(data, e);  //  加载子集
                            strHtml += '</ul>';
                            strHtml += '</li>';
                        } else {
                            strHtml += '<li>'
                                + '<a class="J_menuItem" href="' + e.jumpurl + '"><i class="fa ' + e.iconstyle + '"></i> '
                                + '<span  class="nav-label">' + e.menuname + '</span></a>'
                                + '</li>';
                        }
                    }
                });
                $("#side-menu").html(strHtml);
                $("#side-menu").metisMenu();
            }
        });
    },
    //  递归加载菜单数据
    loadMenus: function (data, d) {
        var strHtml = "";
        $(data).each(function (i, e) {
            if (e.parentcode == d.menucode) {
                if (e.childs > 0) {
                    strHtml += '<li>'
                        + '<a href="#">'
                        + '<span  class="nav-label">' + e.menuname + '</span>'
                        + '<span class="fa arrow"></span>'
                        + '</a>';
                    strHtml += '<ul class="nav nav-third-level">';
                    strHtml += query.loadMenus(data, e);  //  加载子集
                    strHtml += '</ul>';
                    strHtml += '</li>';
                } else {
                    strHtml += '<li>'
                        + '<a class="J_menuItem" href="' + e.jumpurl + '"> '
                        + '<span  class="nav-label">' + e.menuname + '</span></a>'
                        + '</li>';
                }
            }
        });
        return strHtml;
    }

}
